home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / lang / Python16_Src.lha / Python16_Source / Modules / sgimodule.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-08-03  |  1.0 KB  |  60 lines

  1. /* SGI module -- random SGI-specific things */
  2.  
  3. #include "Python.h"
  4.  
  5. #include <sys/types.h>
  6. #include <sys/stat.h>
  7. #include <unistd.h>
  8. #include <fcntl.h>
  9.  
  10. static PyObject *
  11. sgi_nap(self, args)
  12.     PyObject *self;
  13.     PyObject *args;
  14. {
  15.     long ticks;
  16.     if (!PyArg_Parse(args, "l", &ticks))
  17.         return NULL;
  18.     Py_BEGIN_ALLOW_THREADS
  19.     sginap(ticks);
  20.     Py_END_ALLOW_THREADS
  21.     Py_INCREF(Py_None);
  22.     return Py_None;
  23. }
  24.  
  25. extern char *_getpty(int *, int, mode_t, int);
  26.  
  27. static PyObject *
  28. sgi__getpty(self, args)
  29.     PyObject *self;
  30.     PyObject *args;
  31. {
  32.     int oflag;
  33.     int mode;
  34.     int nofork;
  35.     char *name;
  36.     int fildes;
  37.     if (!PyArg_Parse(args, "(iii)", &oflag, &mode, &nofork))
  38.         return NULL;
  39.     errno = 0;
  40.     name = _getpty(&fildes, oflag, (mode_t)mode, nofork);
  41.     if (name == NULL) {
  42.         PyErr_SetFromErrno(PyExc_IOError);
  43.         return NULL;
  44.     }
  45.     return Py_BuildValue("(si)", name, fildes);
  46. }
  47.  
  48. static PyMethodDef sgi_methods[] = {
  49.     {"nap",        sgi_nap},
  50.     {"_getpty",    sgi__getpty},
  51.     {NULL,        NULL}        /* sentinel */
  52. };
  53.  
  54.  
  55. void
  56. initsgi()
  57. {
  58.     Py_InitModule("sgi", sgi_methods);
  59. }
  60.